const { notEmpty , validatorResult } = require("./validator");

/**
 * 用户注册参数验证
 * @param {Object} ctx 
 * @param {Function} next 
 */
exports.register_validator = async (ctx, next) => {
  const errors = {};
  let result = notEmpty(ctx)(errors, "qq_account", "body");
      result = notEmpty(ctx)(errors, "nick_name", "body");
      await validatorResult(result,ctx,next);
};

/**
 * 登录参数验证
 * @param {Object} ctx 
 * @param {Function} next 
 */
exports.login_validator = async (ctx, next) => {
    const errors = {};
    let result = notEmpty(ctx)(errors, "qq_account", "body");
    await validatorResult(result,ctx,next);
};

/**
 * 获取用户好友列表参数验证
 * @param {Object} ctx 
 * @param {Function} next 
 */
exports.user_friends_validator = async (ctx,next) => {
    const errors = {};
    let result = notEmpty(ctx)(errors,"_id","query");
    await validatorResult(result,ctx,next);
} 

/**
 * 添加好友参数验证
 * @param {Object} ctx 
 * @param {Function} next 
 */
exports.add_friend_validator = async (ctx,next) => {
    const errors = {};
    let result = notEmpty(ctx)(errors,"myId","body");
        result = notEmpty(ctx)(errors,"friendId","body");
    await validatorResult(result,ctx,next);
}

/**
 * 修改用户在线状态参数验证
 * @param {Object} ctx 
 * @param {Function} next 
 */
exports.update_line_status_validator = async (ctx,next) => {
    const errors = {};
    let result = notEmpty(ctx)(errors,"_id","body");
        result = notEmpty(ctx)(errors,"line_status","body");
    await validatorResult(result,ctx,next);
}

/**
 * 根据QQ号获取一个用户ID
 * @param {Object} ctx 
 * @param {Function} next 
 */
 exports.get_userId_by_qqAccount_validator = async (ctx,next) => {
    const errors = {};
   let  result = notEmpty(ctx)(errors,"qq_account","query");
    await validatorResult(result,ctx,next);
}
